home *** CD-ROM | disk | FTP | other *** search
- /*************************************************************************
- * Copyright (c) 1989-1992 Stone Design Corp. All rights reserved.
- * programmer: Bill Bumgarner
- * File name: SD_Checker_tx.sl
- * Date: Jul 21 1992
- * Purpose: Map a texture to a surface.
- *
- Variables:
- s_frequency: # of times to repeat textures
- in the s direction
- t_frequency: # of times to repeat textures
- in the t direction
- txmap: full path to the texture map file
-
- s_percent1: percentage of the surface area of each square
- s_percent2: of mixed textures (a 2x2 square) that is
- occupied by each texture.
-
- do_depth_cues: 1 turns on lighting affects (see below)
-
- Ka: percentage of ambient light used
- Kd: percentage of diffuse light used
- Ks: factor of effect for the specular highlight
- roughness: roughness factor for surface; used w/highlight
- specularcolor: color used for specular highlight
- ***************************************************************************/
-
- surface SD_Checker_tx(
- float s_frequency = 1.,
- t_frequency = 1.;
-
- string txmap1 = "",
- txmap2 = "";
-
- float s_percent1 = .5,
- t_percent1 = .5;
-
- float do_depth_cues = 0;
-
- float Ka = 1,
- Kd = .5,
- Ks = .5,
- roughness = .1;
- color specularcolor = 1;
- )
- {
- float ss = mod(s_frequency * s, 1)*2;
- float tt = mod(t_frequency * t, 1)*2;
- point Nf;
-
-
- if( ((ss < (s_percent1*2)) && (tt<(t_percent1*2))) ||
- ((ss > (s_percent1*2)) && (tt>(t_percent1*2))) ){
- if(txmap1 != "")
- Ci = color texture(txmap1, mod(ss,1), mod(tt,1));
- else
- Ci = Cs;
- } else {
- if(txmap2 != "")
- Ci = color texture(txmap2, mod(ss,1), mod(tt,1));
- else
- Ci = Cs;
- }
-
- Oi = Os;
- if(do_depth_cues != 0){
- Nf= faceforward(N, I);
- Ci=Os * (Ci * (Ka*ambient() + Kd*diffuse(Nf)) +
- specularcolor * Ks * specular(Nf,-I,roughness));
- }
- }